<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>ready(fn)</title>
<meta name="keywords" content="jQuery 1.2 API Reference,Visual jQuery 1.2,jQuery doc,jQuery API,jQuery,jQuery 1.2 API 参考文档中文版,中文版" />
<meta name="description" content="jQuery 1.2 API 文档中文版，提供最新版 jQuery 开发帮助。" />
<link rel="stylesheet" type="text/css" href="../../style/jqueryapi.css" />
<script type="text/javascript" src="../../style/lib/jquery126.js"></script>
 </script>
<script type="text/javascript" src="../../style/jqueryapi.js"></script>
<link rel="shortcut icon" href="../../style/img/favicon.ico" />
</head>
<body>
<div id="topnav">
		<a href="http://www.jQuery.com/" title="jQuery官网" target="_blank" class="topnav">jQuery官网</a>
	<span class="topnav">|</span>
	<a href="http://jquery.org.cn/" title="jQuery中文网站" target="_blank" class="topnav">jQuery中文网站</a>
	<span class="topnav">|</span>
	<a href="http://www.cn-cuckoo.com/" title="1.1版译者" target="_blank" class="topnav">为之漫笔</a>
	<span class="topnav">|</span>
	<a href="http://shawphy.com/" title="1.2版翻译整理者" target="_blank" class="topnav">Shawphy</a>
    <span class="topnav">|</span>
	<a href="http://www.51toria.cn" title="CHM文档制作者:一揪" target="_blank" class="topnav">CHM文档制作者</a> 
	<span class="topnav">|</span>
	<a href="http://dl.getdropbox.com/u/81097/jQueryAPI_CHM.CHM" title="" target="_blank" class="topnav">CHM最新版本下载</a> 
</div>
<hr style="color:#595959;" />

<div class="content">
				<h1>ready(fn)</h1>
				<div class="desc"><div>当DOM载入就绪可以查询及操纵时绑定一个要执行的函数。</div> <div class="longdesc"><p>这是事件模块中最重要的一个函数，因为它可以极大地提高web应用程序的响应速度。</p><p>简单地说，这个方法纯粹是对向window.load事件注册事件的替代方法。通过使用这个方法，可以在DOM载入就绪能够读取并操纵时立即调用你所绑定的函数，而99.99%的JavaScript函数都需要在那一刻执行。</p><p>有一个参数－－对jQuery函数的引用－－会传递到这个ready事件处理函数中。可以给这个参数任意起一个名字，并因此可以不再担心命名冲突而放心地使用$别名。</p><p>请确保在 &lt;body&gt; 元素的onload事件中没有注册函数，否则不会触发$(document).ready()事件。</p><p>可以在同一个页面中无限次地使用$(document).ready()事件。其中注册的函数会按照（代码中的）先后顺序依次执行。</p></div></div><hr />
				<div class="desc"><div>Binds a function to be executed whenever the DOM is ready to be traversed and manipulated.</div> <div class="longdesc"><p>This is probably the most important function included in the event module, as it can greatly improve the response times of your web applications.</p><p>In a nutshell, this is a solid replacement for using window.onload, and attaching a function to that. By using this method, your bound function will be called the instant the DOM is ready to be read and manipulated, which is when what 99.99% of all JavaScript code needs to run.</p><p>There is one argument passed to the ready event handler: A reference to the jQuery function. You can name that argument whatever you like, and can therefore stick with the $ alias without risk of naming collisions.</p><p>Please ensure you have no code in your &lt;body&gt; onload event handler, otherwise $(document).ready() may not fire.</p><p>You can have as many $(document).ready events on your page as you like. The functions are then executed in the order they were added.</p></div></div>
				<h2>返回值</h2>
				<p class="indent">jQuery</p>
				<h2>参数</h2>
				<p class="indent"><strong>fn </strong>(Function) : 要在DOM就绪时执行的函数</p>
				<h2>示例</h2>
				<p class="indent">
					在DOM加载完成时运行的代码，可以这样写：
				</p>
				<p class="indent"><strong>jQuery 代码:</strong></p>
				<div class="code">
					$(document).ready(function(){<br/>
&nbsp; // 在这里写你的代码...<br/>
});
				</div>
				<hr />
				<p class="indent">
					使用 $(document).ready() 的简写，同时内部的 jQuery 代码依然使用 $ 作为别名，而不管全局的 $ 为何。
				</p>
				<p class="indent"><strong>jQuery 代码:</strong></p>
				<div class="code">
					jQuery(function($) {<br/>
&nbsp; // 你可以在这里继续使用$作为别名...<br/>
});
				</div>
			</div>
            
</body>
</html>
